home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
2614.ZIP
/
TBROWS.ZIP
/
TTBR6.PRG
< prev
next >
Wrap
Text File
|
1990-10-26
|
5KB
|
201 lines
/*****
*
* TTBR6.PRG
* Sixth example for TBROWSE class using a database file
*
* 20 October 90
* Luiz Quintela - Nantucket Corp
*
* Clipper ttbr6 /N/W/A/B
* RTLINK FILE ttbr6 PLL base50
*
*/
// Include Header Files
#include "inkey.ch"
#include "setcurs.ch"
MEMVAR GetList
FUNCTION Main()
LOCAL b, column, nKey, aColors, bData
SET SCOREBOARD OFF
SET DATE BRITISH
SET CONFIRM ON
USE test INDEX test NEW
// Turn cursor off
SETCURSOR(SC_NONE)
SETCOLOR( "BG/B" ); CLS
b := TBrowseDB( 2, 2, 20, 48)
b:colorSpec := "BG/B,GR+/R,W/N,N,GR+/W,W+/B,R+/B,GR+/B"
b:colSep := " │ "
b:headSep := "═╤═"
b:footSep := "═══"
// TBColumn objects
column := TBColumnNew( "Field 1", {|| test->fld1} )
column:footing := "First"
b:addColumn( column )
column := TBColumnNew( "Field 2", {|| test->fld2} )
b:addColumn( column )
column := TBColumnNew( "Field 3", {|| test->fld3} )
b:addColumn( column )
column := TBColumnNew( "Field 4", {|| test->fld4} )
b:addColumn( column )
column := TBColumnNew( "Field 5", {|| test->fld5} )
// cargo
// is an instance variable of ANY DATA TYPE, allowing
// arbitrary information to be attached to a TBColumn object and
// retrieved later
column:cargo := {|| Recolor(column) }
column:footing := "Last"
bData := column
b:addColumn( column )
// Freeze one column
b:freeze := 1
WHILE .T.
// Do not allow cursor to move into frozen columns
IF ( b:colPos <= 1 )
// As you can see b:colPos is assignable
b:colPos := b:freeze + 1
ENDIF
// Stabilization
WHILE ( !b:stabilize() )
nKey := InKey()
IF ( nKey != 0 )
EXIT // abort if a key is waiting
ENDIF
END
IF ( b:stable )
IF ( b:hitTop .OR. b:hitBottom )
TONE(87.3,1)
TONE(40,3.5)
ENDIF
// everything's done; just wait for a key
nKey := INKEY(0)
ENDIF
// Process key
IF ( nKey == K_DOWN )
b:down()
ELSEIF ( nKey == K_UP )
b:up()
ELSEIF ( nKey == K_PGDN )
b:pageDown()
ELSEIF ( nKey == K_PGUP )
b:pageUp()
ELSEIF ( nKey == K_CTRL_PGUP )
b:goTop()
ELSEIF ( nKey == K_CTRL_PGDN )
b:goBottom()
ELSEIF ( nKey == K_RIGHT )
b:right()
ELSEIF ( nKey == K_LEFT )
b:left()
ELSEIF ( nKey == K_HOME )
b:home()
ELSEIF ( nKey == K_END )
b:end()
ELSEIF ( nKey == K_CTRL_LEFT )
b:panLeft()
ELSEIF ( nKey == K_CTRL_RIGHT )
b:panRight()
ELSEIF ( nKey == K_CTRL_HOME )
b:panHome()
ELSEIF ( nKey == K_CTRL_END )
b:panEnd()
ELSEIF ( nKey == K_ESC )
CLS; SETCURSOR(SC_NORMAL); QUIT
ELSEIF ( nKey == K_F10 )
// Check to see if you are at the right place
IF ( b:colPos == 5 )
// If so, go ahead
// First evaluate bdata:cargo
// Check this evaluation in the UDF Recolor()
// Now, you will replace the old column object
// with the new one
// setColumn( colPos, newObjColumn ) => currentObjColumn
// setColumn replaces the TBColumn object
// The value returned is the current column object
b:setColumn( b:colPos, EVAL( bData:cargo ) )
b:configure() // Causes the TBrowse object to
// re-examine all instance variables and TBColumn
// objects, and them reconfigure its internal settings
// as required
b:refreshAll() // Internally marks all data rows as
// invalid, causing them to be refilled and redisplayed
// during the next stabilize loop
ENDIF
ENDIF
END
FUNCTION Recolor( bBlock )
// You receive the column object in bBlock
LOCAL cScr := SAVESCREEN( 6, 11, 17, 30 )
LOCAL cClr := SETCOLOR( "GR+/N,N/GR+" )
LOCAL nCurs := SETCURSOR(SC_NORMAL)
LOCAL nMenu := 3, nNum := 0.00
@ 6,11 CLEAR TO 17,30
@ 7,13 SAY "Select:"
@ 9,13 PROMPT "Less Than"
@ 11,13 PROMPT "Greater Than"
@ 13,13 PROMPT "Equal to"
MENU TO nMenu
@ 16,13 SAY "Value:" GET nNum PICTURE "99999.99"
READ
// Here you decide what color you will use in your\
// column
IF nMenu == 1
bBlock:colorBlock := { |y| IF(y < nNum, { 7, 2 },;
{ 1, 2 }) }
ELSEIF nMenu == 2
bBlock:colorBlock := { |y| IF(y > nNum, { 6, 2 },;
{ 1, 2 }) }
ELSE
bBlock:colorBlock := { |y| IF(y == nNum, { 8, 2 },;
{ 1, 2 }) }
ENDIF
SETCURSOR(nCurs)
SETCOLOR(cClr)
RESTSCREEN( 6, 11, 17, 30, cScr )
// And return the altered column object
RETURN bBlock
/* EOF - TBBR6.PRG */